<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
</head>
<body>
	<div id="moduleHtml">
	 <div id="notePlainTextContainter">
	   <div id="title" data-options="
	     title : '标题' ,
	     collapsible : false ,
	     region : 'north' ,
	     height : 60
	   ">
	   <input id="idInput" type="hidden" >
	   <input id="titleInput" type="text" >
	   </div>
	   <div id="content" class="easyui-layout" data-options="
	     title : '便签内容' ,
	     region : 'center'
	   ">
	     <div id="dateInputContainter" data-options="
	     collapsible : false ,
	     region : 'north' ,
	     height : 30
	     ">
          <input id="dateInput" >
       </div>
       <div data-options="
	     region : 'center' 
       ">
	       <textarea id="contentInput">xsds</textarea>
	     </div>
	   </div>
	   <div id="buttons" data-options="
	     region : 'south' ,
	     height : 30
	   ">
	     <div id="buttonSubmit">保存</div>
	   </div>
	  </div>
	</div>
</body>
  <script>
  //cofit_module_js
    Cofit.moduleSourceCode.note_calendar_alert=function(dom){
      var module = {
        dom : $(dom) ,        
        inited : false ,
        //显示
        show : function( typeId ,noteId){
		          var dom=$(module.dom).clone();
		          var containter=dom.find("#notePlainTextContainter");
		          
        	    //初始化
		          $("body").append(dom);
		          $(dom).window({    
		        	    title: "新建便签",    
		        	    width: 400,    
		        	    height: 300,    
		        	    closed: false ,    
		        	    cache: false ,    
		        	    modal: false ,
		        	});
		          
		          containter.layout({
		        	  fit : true
		          });
		          containter.find("#content").layout({
		        	  fit : true
		          });
		          
		          containter.find("#buttonSubmit").linkbutton();
		          containter.find("#buttonSubmit").click(function(){
		        	  var param=module.getFormData(containter);
		        	  $.post("./note/save_note",{
		        		  id : param.id ,
		        		  type_id : typeId ,
		        		  title : param.title ,
		        		  content : JSON.stringify(param.content) ,
		        	  },function(resp){
		        		  if(resp.success){
		        			  $.messager.show({
		        				  msg : resp.msg ,
		        			  });
		        			  $(dom).window("close");
		        		  }
		        	  },"json")
		          });
		          
		          
		          
		          var date = new  Date();
		          var m=date.getMonth()+1;
		          m=m>9?m:"0"+m;
		          var d=date.getDate();
		          d=d>9?d:"0"+d;
		          
		          containter.find('#dateInput').datebox({    
		        	  editable : false ,
		        	  value : date.getFullYear()+"-"+m+"-"+d ,
		        	});  		          
		          
		          
		          
		          
		          
		          if(null!=noteId){
		        	  $.get("./note/get_note/"+noteId,{},function(note){
		        		  module.setFormData(containter,note);
		        	  },"json");
		          }
	          
		          module.inited=true;
        },
        setFormData : function(containter,note){
        	containter.find("#idInput").val(note.id);
        	containter.find("#titleInput").val(note.title);
        	var content=JSON.parse(note.noteJson);
        	containter.find("#contentInput").val(content.text);
        	containter.find("#dateInput").datebox("setValue",content.date);
        } ,
        getFormData : function(containter){
        	var title = containter.find("#titleInput").val();
        	if($.trim(title)==""){
        		containter.find("#titleInput").val("无标题");
        		title="无标题";
        	}
        	return {
        		id : containter.find("#idInput").val() ,
        		title : title ,
        		content : {
        			text : containter.find("#contentInput").val() , 
        			date : containter.find("#dateInput").datebox("getValue") ,
        		} ,
        	};
        },
      };
      return module;
    };
  //cofit_module_js
  </script>
</html>